package com.authine.cloudpivot.web.api.service.impl;

import com.authine.cloudpivot.web.api.service.LdapService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.stereotype.Service;

/**
 * @author LiuN
 * @description
 * @date 2021/4/1
 */
@Slf4j
@Service
public class LdapServiceImpl implements LdapService {

    @Autowired
    private LdapTemplate ldapTemplate;

    @Override
    public boolean ldapAuth(String username, String passWord) {
        EqualsFilter filter = new EqualsFilter("sAMAccountName",username);
        return ldapTemplate.authenticate("",filter.toString(),passWord);
    }


}
